package hp.com.servlet.UsersServlet;

import hp.com.service.UsersService;
import hp.com.service.impl.UsersServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/CheckPhone")
public class CheckPhoneValid extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        UsersService us = new UsersServiceImpl();
        String phone = req.getParameter("phone");
        try{resp.getWriter().print(us.checkPhoneValid(phone));
        } catch (Exception e){
            e.printStackTrace();
        }
    }
}
